﻿using ExcellentProject.Dominio.Cuestionarios.Entidades;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace ExcellentProject.Behaviors.Html
{
    public class CommonQuestionRenderBehavior
        : IRenderBehavior<Pregunta>
    {
        public void RenderQuestion(Panel panel, Pregunta question)
        {
            //Question Design 
            #region Statement label
            var statementLabel = new Label()
                {
                    ID = "statementLabel",
                    Text = question.Enunciado
                };
            panel.Controls.Add(statementLabel); 
            #endregion
            
            #region Question Body
            panel.Controls.Add(new HtmlGenericControl("br"));
            int optionNumber = 1;

            foreach (var item in question.Opciones)
            {
                var option = new RadioButton()
                {
                    ID="option" + optionNumber,
                    Text = item.Descripcion
                };
                panel.Controls.Add(option);
                panel.Controls.Add(new LiteralControl("<br />"));
            }
            #endregion
        }
    }
}